<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@include file="/include.inc.jsp" %>
<script type="text/javascript">
	function toAdd(){
		var dictId = $("#dictId").val();
		$.CurrentNavtab.dialog({
		   id:generateMixed(15),
		   type:"post",
		   width:450,
		   height:250,
		   mask:true,
		   url:server+"/sysDict/toAdd",
		   data:{dictId:dictId},
		   title:"添加字典项"
		});
	}
	
	function edit(id){
		$.CurrentNavtab.dialog({
		   id:generateMixed(15),
		   type:"post",
		   width:450,
		   height:250,
		   mask:true,
		   url:server+"/sysDict/detail",
		   data:{id:id},
		   title:"修改字典项"
		});
	}
	
	function mycallback(){
		$.CurrentNavtab.alertmsg("info","删除成功");
		$("#pagerForm").submit();
	}
</script>
<div class="bjui-pageHeader">
	<form method="post" id="pagerForm" action="${path}/sysDict" data-toggle="ajaxsearch" >
		<ul class="bjui-searchBar">
			<li>
				<label class="trtitle01">数据字典：</label>
				<select id="dictId" name="dictId" onchange="changeItem();" data-toggle="selectpicker">
					<c:forEach items="${list}" var="dict">
						<option value="${dict.id}" <c:if test="${dict.id == id}">selected="selected"</c:if>>${dict.C_NAME}</option>
					</c:forEach>
				</select>
			</li>
		</ul>
	</form>
</div>

<div class="pageContent">
	<div class="bjui-headBar">
          <ul>
			<li class="left">
				<a href="javascript:;" onclick="toAdd();" class="btn btn-default" data-icon="save">添加字典项</a>
			</li>
			<li class="left">
				<a href="${path}/sysDict/delItem" class="btn btn-default btn-sm" data-toggle="doajaxchecked" data-type="post" data-confirm-msg="确定要删除选中项吗？" data-icon="trash-o" data-idname="ids" data-group="ids" data-callback="mycallback">批量删除</a>
			</li>
         </ul>
	</div>
	<table data-toggle="tablefixed" data-layout-h="0" data-nowrap="true">
		<tr>
			<th width="35" style="text-align: center;"><input type="checkbox" class="checkboxCtrl" data-group="ids" data-toggle="icheck"/></th>
			<th style="text-align:left;">名称</th>
			<th style="text-align:left;">操作</th>
		</tr>
		<c:forEach items="${items}" var="dictItem">
			<tr>
				<td width="35" style="text-align: center;"><input type="checkbox" name="ids" data-toggle="icheck" value="${dictItem.id}" ></td>
				<td style="text-align:left;">${dictItem.C_NAME}</td>
				<td style="text-align:left;">
					<a href="javascript:;" onclick="edit('${dictItem.id}');" class="btn btn-green" data-icon="edit">编辑</a>
					<a href="${path}/sysDict/delItem?ids=${dictItem.id}" class="btn btn-red" data-toggle="doajax" data-type="post" data-confirm-msg="确定要删除该条数据吗？" data-callback="mycallback">删除</a>
				</td>
			</tr>
		</c:forEach>
	</table>
</div>

<script type="text/javascript">
	// 切换数据字典
	function changeItem(){
		$("#pagerForm").submit();
	}
</script>
